package datastructure.sort;

public class SelectionSort extends AbstractArray {

	public SelectionSort(int max) {
		super(max);
	}

	@Override
	public void sort() {
		selectionSort();
	}

	public void selectionSort() {
		int out, in, min;
		for (out = 0; out < nElems - 1; out++) {
			min = out;
			for (in = out + 1; in < nElems; in++)
				if (a[in] < a[min])
					min = in;
			swap(out, min);
		} // end for(outer)
	} // end selectionSort()

	// =================================
	// +++++++++++++++++++++++++++++++++
	// =================================
	public static void main(String[] args) {

		BubbleSort arr = new BubbleSort(maxSize);
		arr.insert(77);
		arr.insert(99);
		arr.insert(44);
		arr.insert(55);
		arr.insert(22);
		arr.insert(88);
		arr.insert(11);
		arr.insert(00);
		arr.insert(66);
		arr.insert(33);

		System.out.println("Input Array: ");
		arr.display();

		arr.sort();

		System.out.println("\nAfter Bubble sort: ");
		arr.display();
	} // end main()

}
